<?php

require_once(config::getDocRoot().'lib/smarty3/Smarty.class.php');

class umSmarty extends Smarty{
	private static $obj;
	
	public function __construct(){
		parent::__construct();
		
		$this->template_dir		= config::getDocRoot().'templates/';
		$this->compile_dir		= config::getDocRoot().'tmp/smarty_compile/';
		$this->cache_dir		= config::getDocRoot().'tmp/smarty_cache/';
		
		$this->debugging		= false;
		$this->compile_check	= true;
		
		//$this->plugins_dir[]	= PATH_FUNCTIONS.'smarty_plugins/';
		
		//user settings :)
		$user = umUser::getInstance();
		$this->assign('USER', $user);
		
		$this->checkDir($this->compile_dir, true);
		$this->checkDir($this->cache_dir, true);
	}
	
	/**
	 * 
	 * @return mySmarty
	 */
	public static function getInstance(){
		if(!is_object(self::$obj)) self::$obj = new self();
		return self::$obj;
	}
	
	private function checkDir($dir,$create=false){
		if(!is_dir($dir) && $create) mkdir($dir, 0777, true);
		
		return is_dir($dir);
	}
}

